package com.spddr.pmos.repos;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.spddr.pmos.jpa.UserRole;
import com.spddr.pmos.jpa.UserRoleId;

public interface UserRoleRepos extends JpaRepository<UserRole, UserRoleId> {
	List<UserRole> findByIdUser(long user);

	List<UserRole> findByIdRole(long role);

	@Query("DELETE FROM UserRole WHERE id.user = ?")
	void deleteByUser(long user);

	@Query("DELETE FROM UserRole WHERE id.role = ?")
	void deleteByRole(long role);
}
